<!-- 预览 -->
<template>
	<view style="padding-bottom: 20px;">
		<cInformation :userData="userData" /><!-- 基本信息 -->
		<cCertificate :userData="userData" /><!-- 我的证书 -->
		<cGrade :userData="userData" /><!-- 学业成绩 -->
		<cSchoolActivities :userData="userData" /><!-- 校内活动 -->
		<cSchoolAfterActivities :userData="userData" /><!-- 校外活动 -->
		<cProject :userData="userData" /><!-- 参建项目 -->
	</view>
</template>

<script lang="ts" setup>
	import cInformation from "./components/information.vue"; // 基本信息
	import cCertificate from "./components/certificate.vue";// 我的证书
	import cGrade from "./components/grade.vue";// 学业成绩
	import cSchoolActivities from "./components/school-activities.vue";// 校内活动
	import cSchoolAfterActivities from "./components/school-after-activities.vue";// 校外活动
	import cProject from "./components/project.vue";// 参建项目
	import { ref } from 'vue'
	import { onLoad } from '@dcloudio/uni-app'
	
	let userData = ref({
		id: '',
		userId: ''
	})
	onLoad((option) => {
		if (option.userId) {
			userData.value = {
				id: option.id,
				userId: option.userId
			}
		} else {
			let params = {
				id: '',
				userId: ''
			}
			let queryString = decodeURIComponent(option.q)
			let queryArray = queryString.split('?')
			if (queryArray.length > 1) {
				let query = queryArray[1]
				let array = query.split('&')
				array.map((value) => {
					let valueArray = value.split('=')
					if (valueArray.length > 1) {
						// 还需要对value进行解码（可能涉及到在value为中文字符，在赋值到二维码前进行encodeURI编码）
						Object.assign(params, { [valueArray[0]]: decodeURI(valueArray[1]) })
					}
				})
				userData.value = params
			}
		}
	})

</script>

<style lang="scss" scoped>
	::v-deep .uni-section {
		background: #f5f5f5;
	}
</style>